<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: red;
        }
        p{
            width: 100px;
            height: 100px;
            background-color: green;
        }
    </style>
</head>
<body>
    
    <div>
        <p></p>
    </div>


    <script>
        // function fun1(a,b,c){
        //     console.log(a,b,c);
        // }
        // fun1();

        
        var div1=document.querySelector('div');
        var p1=document.querySelector('p');

        // 父子元素之间点击事件优先级
        div1.addEventListener('click',function(){
            console.log('div');
        },false);

        p1.addEventListener('click',function(e){
           
            console.log('p');
            // 使用stoppropagation() 方法阻止事件冒泡
            // 使用onclick=function  注册事件也可以使用这种方法阻止事件冒泡
            
            e.stopPropagation();
        },false);

    </script>
</body>
</html>